package com.newsnetwork.api.controller.user;

import com.newsnetwork.grace.result.CommonJSONResult;
import com.newsnetwork.pojo.bo.RegistLoginBO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @author: HuangDekai
 * @date: 2022/11/3 0:19
 * @version: 1.0
 * @since: jdk8
 */
@Api(value = "用户注册登录", tags = {"用户注册登录的controller"})
@RequestMapping("passport")
public interface PassportControllerApi {
    @ApiOperation(value = "获得短信验证码", notes = "获得短信验证码", httpMethod = "GET")
    @GetMapping("/getSMSCode")
    CommonJSONResult getSMSCode(@RequestParam String mobile, HttpServletRequest request);

    @ApiOperation(value = "一键注册登录接口", notes = "一键注册登录接口", httpMethod = "POST")
    @PostMapping("/doLogin")
    CommonJSONResult doLogin(@RequestBody @Valid RegistLoginBO registLoginBO,
                             HttpServletRequest request,
                             HttpServletResponse response);

    /**
     * 用户退出 - 删除 redis 中的 utoken, cookie 中的 utoken 和 uid
     * @param userId 用户 id
     * @param request 请求
     * @param response 响应
     * @return CommonJSONResult.OK()
     */
    @ApiOperation(value = "用户退出登录接口", notes = "用户退出登录", httpMethod = "POST")
    @PostMapping("/logout")
    CommonJSONResult logout(@RequestParam String userId,
                             HttpServletRequest request,
                             HttpServletResponse response);
}
